1. Field of the Invention
The present invention relates to a method for receiving data by a universal asynchronous receiver transmitter. More particularly, the present invention relates to a method for receiving data by using a good data length register (GDL) installed in a universal asynchronous receiver transmitter to count the number of correct data so as to enhance the performance of reading data.
2. Description of Related Art
As communication originally refers to the communication of ideas or the exchange of information, but communication nowadays also includes a wireless or a cable transmission of multimedia information such as sound, image and text to a remote end. From the technical definition of communication, various signals can be sent successfully, efficiently and safely to a remote place after being coded and modulated, and an “electric” transmission function is used to rapidly and conveniently view a television program, make a phone call, listen to a radio broadcast, transmit a document as well as use a wireless or cable modem to send or receive emails through the Internet, browse a webpage and use an Internet phone, etc through the network.
At present, network has become the second largest medium, which is an indispensable information source to most people and an important channel for the communication between people. If a network transmission is considered as a highway, then every user must have a receiver transmitter for sending or receiving information distributed on the highway. As the transmitting speed is increasing constantly, the receiver transmitter must come with a fast operating speed as well. Now, the most popular receiver transmitter is the universal asynchronous receiver transmitter (UART) which is also known as the serial communication interface (SCI). This kind of universal asynchronous receiver transmitter is a serial interface RS-232 installed in an electronic product such as a general instrument, a computer or a PDA and it is the current mainstream of serial transmissions.
When universal asynchronous receiver transmitter transmits data, the operation time of transmitter and receiver is asynchronous. It means that the transmitter sent the data irregularly to receiver. In order to set the space between serial data, it will set a start bit and an end bit to transmit the serial data successfully.
Please refer to FIG. 1 for the schematic view of the process of reading data by a traditional universal asynchronous receiver transmitter. In the figure, when the universal asynchronous receiver transmitter A receives a serial data, the serial data is saved in a receive shift register (RSR) A1, and the receive shift register A1 also saves the start bit, end bit and data bits of each record of the serial data. However, since the receive shift register A1 has no mapping for the memory address, therefore the data of the receive shift register A1 cannot be accessed directly. After the receive shift register A1 has received an end bit, a data bit in the receive shift register A1 will be sent to a receiver FIFO A2, and a line status register A3 will identify whether the data is correct. In the process of receiving a serial data, an end bit should be received after all data bits are received. If an end bit is not received at that time, a frame error will occur. Further, if a parity check mechanism is enabled and the received parity bit is incorrect, then a parity error will be generated, and the parity bit in the line status register A3 sets as an error. If an end bit is received after all data bits are received, then the line status register A3 sets as correct. FIGS. 2, 3, 4, 5, 6, 7 and 8, show the schematic views of a process of reading data by a prior-art universal asynchronous receiver transmitter, wherein when a microprocessor B reads a serial data in the receiver buffer register A4 through a bus C, each record of data will be read twice sequentially, wherein during the first time, the microprocessor B will read the line status register A3 for gauging whether the data is correct or not, and then during the second time, according to the first time reading result, the microprocessor B+ will read the correct data stored in the receiver buffer A4 and read error data and stored in the line status register A3. In this example, six serial data stored in the receiver buffer A4 are read according to the aforementioned method, the microprocessor B will read 12 times including six times reading of the receiver buffer A4 and six times reading of the line status register A3.
However, when the foregoing prior-art universal asynchronous receiver transmitter A is receiving data, it is necessary to read every record of data twice before retrieving the data, and such process increases the workload of the microprocessor B and lowers its performance. The current electronic products emphasize on an all-in-one design, and the microprocessor B will be unable to process other work in a high performance or the processing speed will become very slow. Such prior art definitely causes inconvenience to users.
Therefore, it is desirable to provide a method for receiving data by a universal asynchronous receiver transmitter that eliminates the aforesaid drawbacks.